<template>
	<!-- 交易记录 -->
	<view :class="['vh100',{'dark':theme == 'dark'}]">
		
		<!-- <view class="bgHeader h10"></view> -->
		<view class="plr10 ptb15 mt10 bgPart" style="min-height: 80vh;">
			<!-- <view class="ft16">{{$t('assets.records')}}</view> -->
			<view class="mt10 pb100">
				<view class="flex alcenter ptb10 bdb_blue3 nWhite">
					<view class="flex1 fx2">{{$t('trade.num')}}</view>
					<view class="flex1 fx2">{{$t('assets.record')}} {{currency}}</view>
					<view class="flex1 fx2 tr">{{$t('trade.time')}}</view>
				</view>
				<view class="mt10 flex bdb_blue3 ptb5" v-for="(item,i) in logList" :key="i" v-if="logList.length>0">
					<view class="flex1">{{item.symbol}} {{item.flowPrice-0}}</view>
					<!-- <view class="flex1 ">{{typeMap(item.fType)}}</view> -->
					<view class="flex1 ">{{item.flowType}}</view>					
					<view class="flex1 tr">{{item.createTime}}</view>
				</view>
				<view class="mt20 tc" v-if="logList.length==0">
					<image src="/static/image/nodata.png" class="h50 wt50"></image>
					<view>{{$t('home.norecord')}}</view>
				</view>
			</view>
		</view>
		<view class="fixed pos_l0b0 w100 bgHeader bdt2f flex alcenter ptb10 zdx100">
		</view>
	</view>
</template>

<script>
	import {mapState,mapActions,mapGetters} from 'vuex';
	import {cashflow} from '../../common/apiString.js';
	import typeMap from "../../common/cashFlowType.js"
	import {myMixins} from '@/common/myMixins.js'
	export default{
		mixins:[myMixins],
		data(){
			return {
				currency:'',
				tradeType:'',
				page:1,
				coinInfo:{},
				logList:[],
				titles:[
					{//钱包
					name: this.$t('assets.wallet'),
					id: 'WALLET'
				// }, {//币币
				// 	name: this.$t('assets.trade'),
				// 	id: 'CURRENCY'
				}, {//合约
					name: this.$t('assets.lever'),
					id: 'CONTRACT'
				}, {//法币
				 	name: this.$t('assets.legal'),
				 	id: 'LEGAL'
				}, {//期权
				 	name: this.$t('assets.option'),
				 	id: 'OPTION'
				},{//矿机
				 	name: "矿机",
				 	id: 'MINING'
				},
				],
				ExRate:6.5,
			}
		},
		computed:{
			...mapState({
			  theme:state=>state.theme
			}),
		},
		
		onLoad(e) {
			this.currency=e.currency;
			this.tradeType=e.type;
			console.log(e)
			var that=this;
			uni.setNavigationBarTitle({
				title:that.titles[e.type].name
			})
			// if(e.type=='change'){
			// 	uni.setNavigationBarTitle({
			// 		title:that.titles[0]
			// 	})
			// }else if(e.type=='lever'){
				
			// }else{
			// 	uni.setNavigationBarTitle({
			// 		title:that.titles[2]
			// 	})
			// }
		},
		onShow() {
			this.$utils.setTheme(this.theme);
			this.getDetail();
			this.getLog();
		},
		methods:{
			typeMap(val){
				return typeMap(val)
			},
			getDetail(){
				
			},
			goTrade(){
				let localData=uni.getStorageSync('tradeData')||{};
				let currency_name=this.coinInfo.currency_name;
				console.log(uni.getStorageSync('tradeData'),localData)
				if(localData.legal_name &&localData.legal_name!=currency_name){
					console.log(123);
					localData.currency_name=currency_name;
					localData.currency_id=this.currency;
					uni.setStorageSync('tradeData',localData);
				}
				uni.switchTab({
					url:'/pages/trade/trade'
				})
			},
			getLog(){
				let dto = {
					type:this.titles[this.tradeType].id,
					symbols:this.currency	
				};
				this.$utils.initDataToken({url:cashflow,type:'GET', data:dto},
				res=>{
					//console.log(res)
					//debugger
					//this.ExRate=res.ExRate-0;
					uni.stopPullDownRefresh()
					this.logList=res.records.records;
				})
			}
		},
		onPullDownRefresh() {
			this.page=1;
			this.logList=[];
			this.getDetail();
			this.getLog();
		},
		onReachBottom() {
			this.page++;
			this.getLog();
		}
	}
</script>

<style lang="scss">
	page{
		background: #FFFFFF;
	}
	.wt50 {
	    width: 35px;
	    height: 40px;
	}
	.ptb15 {
	    padding-top: 0px;
	    padding-bottom: 15px;
	}
	.fx2 {
	       font-size: 3.4vw;
	       font-weight: 700;
	}
</style>
